// doc是注入，这样使得document为一个局部对象，不用到全局去取
; (function (Comment) {

  var oOpenBtn = $get('.J_openBtn')[0],
    oCloseBtn = $get('.J_closeBtn')[0],
    oStars = $get('.J_stars')[0],
    oEditTxt = $get('.J_editTxt')[0],
    oSubmitBtn = $get('.J_submitBtn')[0],
    oRadioTabs = $get('.J_radioTabs')[0],
    oBtnBox = $get('.J_btnBox')[0];

  var userId = 1;

  // 初始化函数
  var init = function () {
    Comment.getComments({
      fieldId: 0,
      pageNum: 1
    });
    bindEvent();
  }

  // 管理所有 绑定事件集和 函数
  function bindEvent() {
    oOpenBtn.addEventListener('click', Comment.openBoard, false);
    oCloseBtn.addEventListener('click', Comment.closeBoard.bind(Comment), false);
    oStars.addEventListener('mouseover', Comment.starsHover, false);
    oEditTxt.addEventListener('input', Comment.editInput.bind(Comment), false);
    oSubmitBtn.addEventListener('click', Comment.submitComment.bind(Comment, userId), false);
    oRadioTabs.addEventListener('click', Comment.radioTabClick.bind(Comment), false);
    oBtnBox.addEventListener('click', Comment.pageBtnClick.bind(Comment), false);
  }

  // 执行初始化函数
  init();

})(initCommentModule);